<template>
  <div class="card" @click="goToPlayer">
    <img :src="cardData.image" :alt="cardData.title" class="card-image" />
    <div class="card-content">
      <div class="card-meta">{{ cardData.category }} / {{ cardData.duration }}</div>
      <h3 class="card-title">{{ cardData.title }}</h3>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps } from 'vue';
import { useRouter } from 'vue-router';

const props = defineProps({
  cardData: {
    type: Object,
    required: true
  }
});

const router = useRouter();

const goToPlayer = () => {
  router.push('/player'); // 跳转到播放器页面
};
</script>

<style scoped>
.card {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #ddd;
  cursor: pointer; /* 添加可点击样式 */
}

.card-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
}

.card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: #fff;
  padding: 1rem;
}

.card-meta {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.card-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.4;
}
</style>